//
//  AppDelegate.swift
//  WeiBoAPP
//
//  Created by 张学飞 on 2018/12/27.
//  Copyright © 2018 zxf. All rights reserved.
//

import UIKit
import CoreData
import UserNotifications
import SVProgressHUD
import AFNetworking

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        
        setupAddtions(application: application)
        
//        sleep(2)
        window = UIWindow()
        window?.backgroundColor = UIColor.white
        window?.rootViewController = ZFMainViewController()
        window?.makeKeyAndVisible()
        
        window?.backgroundColor = UIColor(hexString: "0xffffff")

    
        
        return true
    }

}


extension AppDelegate {


}
extension AppDelegate {
    
    private func setupAddtions (application:UIApplication) {
    
        SVProgressHUD.setMinimumDismissTimeInterval(1)
        AFNetworkActivityIndicatorManager.shared().isEnabled = true
    
        if #available(iOS 10.0, *) {
            UNUserNotificationCenter.current().requestAuthorization(options: [.alert,.badge,.carPlay,.sound]) { (success, error) in
                
                print("授权" + (success ? "成功" : "失败"))
            }
        } else {
            // Fallback on earlier versions
            //取得用户授权，通知上方提示条，声音，badgeNumber
            let notifaySetting = UIUserNotificationSettings(types:[.alert,.badge,.sound]
                , categories: nil)
            application.registerUserNotificationSettings(notifaySetting)
            
        }

    }
    
}
